<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right" style="font-size:18px ">
      <el-breadcrumb-item :to="{ path: '/' }"><i class="el-icon-s-promotion"></i> 后台管理</el-breadcrumb-item>
      <el-breadcrumb-item>添加管理员</el-breadcrumb-item>
    </el-breadcrumb>

    <el-divider style="margin-bottom: 50px"></el-divider>

    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="管理员名称" prop="username">
        <el-input v-model="ruleForm.username"></el-input>
      </el-form-item>
      <el-form-item label="管理员密码" prop="password">
        <el-input v-model="ruleForm.password"></el-input>
      </el-form-item>
      <el-form-item label="管理员昵称" prop="nickname">
        <el-input v-model="ruleForm.nickname"></el-input>
      </el-form-item>
      <el-form-item label="头像URL" prop="avatar">
        <el-input v-model="ruleForm.avatar"></el-input>
      </el-form-item>
      <el-form-item label="手机号码" prop="phone">
        <el-input v-model="ruleForm.phone"></el-input>
      </el-form-item>
      <el-form-item label="电子邮箱" prop="email">
        <el-input v-model="ruleForm.email"></el-input>
      </el-form-item>
      <el-form-item label="简介" prop="description">
        <el-input v-model="ruleForm.description"></el-input>
      </el-form-item>
      <el-form-item label="是够启用" prop="enable">
        <el-switch
            v-model="ruleForm.enable"
            :active-value="1"
            :inactive-value="0"
            active-color="#13ce66"
            inactive-color="#ccc">
        </el-switch>
      </el-form-item>
      <el-form-item label="角色">
        <el-select v-model="ruleForm.role" placeholder="角色">
          <el-option label="角色1" value="shanghai"></el-option>
          <el-option label="角色2" value="beijing"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')">添加</el-button>
        <el-button @click="resetForm('ruleForm')">退出</el-button>
      </el-form-item>
    </el-form>

  </div>
</template>

<script>
export default {
  name: "AttributeAddNewView",
  data() {
    return {
      ruleForm: {
        username: '',
        password: '',
        nickname: '',
        avatar: '',
        phone: '',
        email: '',
        description: '',
        enable: 1
      },
      rules: {
        /*trigger表示检查什么情况会触发，blur表示当控件丢失焦点时触发检查*/
        username: [
          {required: true, message: '请输入管理员名称', trigger: 'blur'},
          {min: 2, max: 15, message: '属性必须在 2 到 15 个字符', trigger: 'blur'}
        ],
        password: [
          {required: true, message: '请输入密码', trigger: 'blur'},
          {min: 2, max: 15, message: '属性必须在 2 到 15 个字符', trigger: 'blur'}
        ],
        nickname: [
          {required: true, message: '请输入昵称', trigger: 'blur'},
          {min: 2, max: 15, message: '属性必须在 2 到 15 个字符', trigger: 'blur'}
        ],
        avatar: [
          {required: true, message: '请输入头像URL', trigger: 'blur'},
          {min: 2, max: 15, message: '属性必须在 2 到 15 个字符', trigger: 'blur'}
        ],
        phone: [
          {required: true, message: '请输入电话号码', trigger: 'blur'},
          {min: 2, max: 11, message: '属性必须在 2 到 15 个字符', trigger: 'blur'}
        ],
        email: [
          {required: true, message: '请输入属邮箱信息', trigger: 'blur'},
          {pattern: /^$/, message: '排序序号必须在 0 到 99 数字之间', trigger: 'blur'}
        ],
        description: [
          {required: true, message: '请输入简介信息', trigger: 'blur'},
          {min: 2, max: 15, message: '属性必须在 2 到 15 个字符', trigger: 'blur'}
        ],

      }
    };
  }, methods: {
    submitForm(formName) {
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    }
  }, mounted() {
    this.loadFromwork();
  }
}
</script>

<style scoped>

</style>